class Triangle {
    double x;
    double y;
    double z;

    public Triangle(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }
    //自定义异常
    public class NotTriangleException extends Exception{
        public NotTriangleException(String s){
            super(s);
        }
    }
    public void  getArea() throws NotTriangleException{
        if(x+y>z && x+z>y && y+z>x){
            System.out.println("两边之和大于第三边,三角形成立,三角形面积为底成高除2");
        }else throw new NotTriangleException( x +" "+z +" "+y+"两边之和小于或等于第三边所以三角形不成立,求不了面积");
    }
    public void showlnfo() throws NotTriangleException{
        //先判断三角形成不成立
        if(x+y>z && x+z>y && y+z>x){
            System.out.println("两边之和大于第三边,三角形成立,三边长分别为 "+ x +" "+z +" "+y);
        }else throw new NotTriangleException( x +" "+z +" "+y+"两边之和小于或等于第三边所以三角形不成立");
    }
}
public class Test {
    public static void main(String[] args) {
        Triangle triangle =new Triangle(3,2,1);
        try {
            triangle.getArea();
        }catch (Triangle.NotTriangleException e){
            e.printStackTrace();
        }
        try {
            triangle.showlnfo();
        }catch (Triangle.NotTriangleException e){
            e.printStackTrace();
        }
    }
}
